﻿/****************************** Module Header ******************************\
 * Module Name:  mxDbCommand.cs
 * Module Version:  1.0.0 (2014-2-27)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to extension collection instance's method.  It supplies 
 * useful extension methods, such as ToString(), FetchString() and so on.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;

namespace UCL.Data
{
    /// <summary>
    /// 数据库命令对象扩展类
    /// </summary>
    public static class mxDbCommand
    {
        /// <summary>
        /// 添加参数
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="dbtype"></param>
        /// <returns></returns>
        /// <remarks>2014-2-27 by sutroon</remarks>
        public static DbParameter AddParameter(this DbCommand cmd, string name, object value, DbType dbtype = DbType.String)
        {
            DbParameter p = cmd.CreateParameter();
            p.ParameterName = name;
            p.Value = value;
            p.DbType = dbtype;
            cmd.Parameters.Add(p);
            return p;
        }
    }
}
